package com.lenovo.smarttraffic.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lenovo.smarttraffic.Constant;
import com.lenovo.smarttraffic.R;
import com.lenovo.smarttraffic.bean.TrafficNewsBean;

/**
 * Created by Caleb.F
 * on 2019-12-30
 * at 14:18
 */
public class TrafficDetailActivity extends BaseActivity {
    private TextView mTvCate;
    private TextView mTvTime;
    private TextView mTvContent;
    private ImageView mIvSpot;
    private String category;
    private TrafficNewsBean mTrafficNewsBean;
    private static final String TAG = "TrafficDetailActivity";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundleExtra = getIntent().getBundleExtra(Constant.TRAFFIC_ITEM_INTENT_DETAIL);
        category = bundleExtra.getString(Constant.TRAFFIC_FRAGMENT_CATEGORY);
        mTrafficNewsBean = (TrafficNewsBean) bundleExtra.getSerializable(Constant.TRAFFIC_ITEM_DETAIL);
        initView();
    }

    private void initView() {
        mTvCate = findViewById(R.id.tv_cate);
        mTvTime = findViewById(R.id.tv_time);
        mTvContent = findViewById(R.id.tv_content);
        mIvSpot = findViewById(R.id.iv_spot);
        initToolBar(mTrafficNewsBean.getTitle());
        mTvCate.setText("分类:" +category);
        mTvTime.setText("时间:"+mTrafficNewsBean.getCreateTime());
        mTvContent.setText("  "+mTrafficNewsBean.getContent());
        if(!TextUtils.isEmpty(mTrafficNewsBean.getImageUrl())){
            Glide.with(this).asBitmap().load(mTrafficNewsBean.getImageUrl()).into(mIvSpot);
        }
        else {
            mIvSpot.setVisibility(View.GONE);
        }
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_traffic_detail;
    }
}
